home *** CD-ROM | disk | FTP | other *** search
/ AGA Toolkit '97 / The AGA Toolkit '97.iso / text / misc / port / string / numtostr-020.s < prev    next >
Encoding:
Text File  |  1996-09-07  |  566 b   |  38 lines

  1.  
  2.     XDEF    NumToStr
  3.  
  4. ; Args:
  5. ; A0  Pointer to space for the converted ASCII number. (11 bytes)
  6. ; D0  32 bit number to convert.
  7.  
  8. ; Returns:
  9. ; A0  Pointer to a ASCII number string.
  10. ; D0  Length of the string.
  11.  
  12. ; A1 & D1 will be trashed.
  13.  
  14.     MACHINE    68020
  15.  
  16. NumToStr:
  17.     movem.l    d2,-(sp)
  18.     add.l    #10,a0
  19.     clr.b    (a0)            ; Clear the last byte of the string
  20.     subq.l    #1,a0
  21.     moveq    #0,d2
  22.  
  23. NumToStr1:
  24.     moveq    #0,d1
  25.     divu.l    #10,d1:d0
  26.     move.b    d1,(a0)
  27.     add.b    #"0",(a0)
  28.     addq.w    #1,d2
  29.     tst.l    d0
  30.     beq    N2A_Finished
  31.     subq.l    #1,a0
  32.     bra    NumToStr1
  33.  
  34. N2A_Finished:
  35.     move.l    d2,d0
  36.     movem.l    (sp)+,d2
  37.     rts
  38.